?><?
function array_as_list($array,$addquotes=true,$separator=","){
	$result="";
	foreach($array as $value){
		if(is_a($value,"cls_entity_item")){
			$result.=($result!=""?$separator:"").($addquotes?"\"":"").$value->id().($addquotes?"\"":"");
		}else{
			$result.=($result!=""?$separator:"").($addquotes?"\"":"").$value.($addquotes?"\"":"");
		}
	}
	return $result;
}
function array_as_id_list($array,$addquotes=true,$separator=","){
	$list=array_as_list($array,$addquotes,$separator);
	return $list?$list:0;
}

function stripslashes_recursive($var) {
	return (is_array($var) ? array_map('stripslashes_recursive', $var) : stripslashes($var));
}

function search_id($id,$list){
  foreach($list as $key=>$object){
    if($object->id==$id){
      return $object;
    }
  }
  return false;
}

function remove_array($list,$remove){
  $idx=0;
  while($idx<count($list)){
    if(search_id($list[$idx]->id,$remove)!==false){
      unset($list[$idx]);
    }else{
      $idx++;
    }
  }
  return $list;
}

function array_trim($array,$save_keys=false){
	$result=array();
	foreach($array as $key=>$value){
		if(trim($value)){
			if($save_keys!==false){
				$result[$key]=$value;
			}else{
				$result[]=$value;
			}
		}
	}
	return $result;
}